Conditions | 2 |
Total Lines | 28 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {Inject} from '@nestjs/common'; |
||
15 | |||
16 | public async execute( |
||
17 | query: GetCustomersQuery |
||
18 | ): Promise<Pagination<CustomerView>> { |
||
19 | const customerViews: CustomerView[] = []; |
||
20 | const [customers, total] = await this.customerRepository.findCustomers( |
||
21 | query.page |
||
22 | ); |
||
23 | |||
24 | for (const customer of customers) { |
||
25 | const address = customer.getAddress(); |
||
26 | |||
27 | customerViews.push( |
||
28 | new CustomerView( |
||
29 | customer.getId(), |
||
30 | customer.getName(), |
||
31 | new AddressView( |
||
32 | address.getId(), |
||
33 | address.getStreet(), |
||
34 | address.getCity(), |
||
35 | address.getZipCode(), |
||
36 | address.getCountry() |
||
37 | ) |
||
38 | ) |
||
39 | ); |
||
40 | } |
||
41 | |||
42 | return new Pagination<CustomerView>(customerViews, total); |
||
43 | } |
||
45 |